package com.jy.modules.cims.common.open.api.dto;

import java.util.List;

import org.hibernate.validator.constraints.NotBlank;

import com.jy.modules.cims.common.open.api.enums.EntryResponseEnum;

public class ResponseData<T> {
	/**响应编码*/
	@NotBlank(message = "响应编码 retCode 不能为空")
	private String retCode;
	
	/**响应信息*/
	@NotBlank(message = "响应信息 message 不能为空")
	private String message;
	
	/**方法名*/
	@NotBlank(message = "方法名 method 不能为空")
	private String method;
	
	private String originalData;
	
	/**响应主体*/
	private T data;
	
	/**响应主体*/
	private List<T> dataList;
	
	/**请求参数中的签名*/
	@NotBlank(message = "请求参数中的签名 sign 不能为空")
	private boolean sign;

	public static <T> ResponseData<T> fromResponseContent(ResponseContent rc,
			Class<T> c) {
		ResponseData<T> rd = new ResponseData<T>();
		rd.setRetCode(rc.getRetCode());
		rd.setMessage(rc.getMessage());
		rd.setMethod(rc.getMethod());
		rd.setOriginalData(rc.getData());
		rd.setSign(false);
		return rd;
	}

	public String getRetCode() {
		return this.retCode;
	}

	public void setRetCode(String retCode) {
		this.retCode = retCode;
	}

	public String getMessage() {
		return this.message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return this.data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public List<T> getDataList() {
		return this.dataList;
	}

	public void setDataList(List<T> dataList) {
		this.dataList = dataList;
	}

	public boolean successVisit() {
		return EntryResponseEnum.isSuccess(this.retCode);
	}

	public String getOriginalData() {
		return this.originalData;
	}

	public void setOriginalData(String originalData) {
		this.originalData = originalData;
	}

	public String getMethod() {
		return this.method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	public boolean isSign() {
		return this.sign;
	}

	public void setSign(boolean sign) {
		this.sign = sign;
	}
}
